package org.juiceshop.gm;

import java.util.Map;


public class Phrase extends MusicContainer {
	
		
	public Phrase (MusicObject...objects) {
		super(objects);
	}
	
	public Phrase (Map<String,Object> args, MusicObject...objects) {
		this(objects);
		setValues(args);
	}
			
	@Override
	public double getValue() {
		double value = 0d;
		for (MusicObject x : this) {
			value += x.getValue();
		}
		return value;
	}
	
	public Phrase append(MusicObject obj) {
		if (obj instanceof Phrase) {
			for (MusicObject elem : (Phrase)obj) {
				add(elem);
			}
		} else {
			add(obj);
		}
		return this;
	}
	
	
	@Override
	public Phrase or (MusicObject obj) {
		return copy().append(obj);
	}
	
		
	public void setArpeggio (double arpeggio) {
		for (MusicObject obj : this) {
			if (obj instanceof Chord) {
				((Chord)obj).setArpeggio(arpeggio);
			}
		}
	}
	
	@Override
	public Phrase copy() {
		return (Phrase)super.copy();
	}
		
	@Override
	public String toString() {
		return toString('|');
	}

}
